﻿using System.Collections.Generic;
using System.Linq;
using System.Text;
using WYJCore.Extension;

namespace WYJWeb
{
    public class Menu:ITree<Menu>
    {
        public int NodeId { get; set; }
        public string Description { get; set; }
        public string Icon { get; set; }
        public string Url { get; set; }
        public string Href => Url.IsNullOrEmpty()? null : "href=" + Url;
        public List<Menu> SubNodes { get; set; }

        public string Raw(string tmpl)
        {
            return new StringBuilder().AppendFormat(tmpl, NodeId, Href, Icon, Description, SubNodes?.Select(x => x.Raw(tmpl)).JoinToString("")).ToString();
        }
    }
}